package com.employee.controller;

import com.employee.pojo.dto.AddScheduleDTO;
import com.employee.pojo.dto.UpdateScheduleDTO;
import com.employee.pojo.entry.Schedule;
import com.employee.pojo.result.Result;
import com.employee.service.ScheduleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
public class ScheduleController {
    @Autowired
    ScheduleService scheduleService;
    @GetMapping("/getScheduleList")
    public Result<List<Schedule>> getScheduleList(){
        System.out.println("---------------------");
        return Result.success(scheduleService.getScheduleList());
    }
    @PostMapping("/addSchedule")
    public Result addSchedule(@RequestBody AddScheduleDTO addScheduleDTO){
        System.out.println("-----------------------------------");
        scheduleService.addSchedule(addScheduleDTO);
        return Result.success();
    }
    @GetMapping("/deleteSchedule/{id}")
    public Result deleteSchedule(@PathVariable Integer  id){
        scheduleService.deleteSchedule(id);
        return Result.success();
    }
    @PostMapping("updateSchedule")
    public Result updateSchedule(@RequestBody UpdateScheduleDTO updateScheduleDTO){
        scheduleService.updateSchedule(updateScheduleDTO);
        return Result.success();
    }

}
